package org.mbari.vcr.timer;

import org.mbari.vcr.IVCR;
import org.mbari.vcr.IVCRState;

/**
 * TimerTask that reads the VTimeCode if the vcr is playing, otherwise it 
 * requests the LTimeCode
 * 
 * @author brian
 */
public class ReadTimecodeTimerTask extends VCRTimerTask {

    public ReadTimecodeTimerTask() {
        super();
    }

    public void run() {
        IVCR vcr = getVcr();
        /*
         * LTimeCode is on the audio track. It's slightly less accurate than
         * the VTimeCode, however, the VTimeCode can't be read except when
         * the VCR is playing. So use the LTimeCode for everything but
         * play mode.
         */
        if (vcr != null) {
            IVCRState state = vcr.getVcrState();
            if (state != null) {
                if (state.isPlaying()) {
                    vcr.requestVTimeCode();
                }
                else {
                    vcr.requestLTimeCode();
                }
            }
        }
    }
}
